package tcp

import (
	"context"
	"gitee.com/kristas/booting-go/framework/core/ioc/bean_factory"
	"gitee.com/kristas/booting-go/framework/core/log"
	"net"
)

type Dialer struct {
}

func NewDialer() *Dialer {
	return &Dialer{}
}

func (r *Dialer) Dial(context context.Context, addr string) (net.Conn, error) {
	tcpAddr, _ := net.ResolveTCPAddr("", addr)
	logger := bean_factory.GetApplicationContext().GetBeanByInterface(new(log.Logger)).(log.Logger)
	logger.Info("[TCP] Dial [%s]", addr)
	return net.DialTCP("tcp4", nil, tcpAddr)
}
